package jy.model;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Order entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "order", catalog = "waimai")
public class Order implements java.io.Serializable {

	// Fields

	private Integer id;
	private User userByOuId;
	private User userByRuId;
	private Store store;
	private Timestamp odtime;
	private String state;
	private Float price;
	private String location;
	private Integer pretime;
	private String destination;
	private Set<Ofood> ofoods = new HashSet<Ofood>(0);

	// Constructors

	/** default constructor */
	public Order() {
	}

	/** minimal constructor */
	public Order(User userByOuId, User userByRuId, Store store,
			Timestamp odtime, String state, Float price, String location,
			Integer pretime, String destination) {
		this.userByOuId = userByOuId;
		this.userByRuId = userByRuId;
		this.store = store;
		this.odtime = odtime;
		this.state = state;
		this.price = price;
		this.location = location;
		this.pretime = pretime;
		this.destination = destination;
	}

	/** full constructor */
	public Order(User userByOuId, User userByRuId, Store store,
			Timestamp odtime, String state, Float price, String location,
			Integer pretime, String destination, Set<Ofood> ofoods) {
		this.userByOuId = userByOuId;
		this.userByRuId = userByRuId;
		this.store = store;
		this.odtime = odtime;
		this.state = state;
		this.price = price;
		this.location = location;
		this.pretime = pretime;
		this.destination = destination;
		this.ofoods = ofoods;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ou_id", nullable = false)
	public User getUserByOuId() {
		return this.userByOuId;
	}

	public void setUserByOuId(User userByOuId) {
		this.userByOuId = userByOuId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ru_id", nullable = false)
	public User getUserByRuId() {
		return this.userByRuId;
	}

	public void setUserByRuId(User userByRuId) {
		this.userByRuId = userByRuId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "store_id", nullable = false)
	public Store getStore() {
		return this.store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	@Column(name = "odtime", nullable = false, length = 0)
	public Timestamp getOdtime() {
		return this.odtime;
	}

	public void setOdtime(Timestamp odtime) {
		this.odtime = odtime;
	}

	@Column(name = "state", nullable = false, length = 10)
	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Column(name = "price", nullable = false, precision = 12, scale = 0)
	public Float getPrice() {
		return this.price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	@Column(name = "location", nullable = false, length = 100)
	public String getLocation() {
		return this.location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	@Column(name = "pretime", nullable = false)
	public Integer getPretime() {
		return this.pretime;
	}

	public void setPretime(Integer pretime) {
		this.pretime = pretime;
	}

	@Column(name = "destination", nullable = false, length = 100)
	public String getDestination() {
		return this.destination;
	}

	public void setDestination(String destination) {
		this.destination = destination;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "order")
	public Set<Ofood> getOfoods() {
		return this.ofoods;
	}

	public void setOfoods(Set<Ofood> ofoods) {
		this.ofoods = ofoods;
	}

}